{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import pandas\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "df = pandas.read_csv('Debug答案溯源-工作表1.csv')[:50]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 提取id列作为key，提取源文件列作为value # 将id转化为int\n",
    "id2source = {int(row['id']): row['源文件'] for _, row in df.iterrows()}\n",
    "# 遍历value，如果是None，则移除key，如果有两个 \".txt\" 在字段中，也移除\n",
    "id2source = {int(k): v.replace(\"\\\\\", \"/\") for k, v in id2source.items() if v is not np.nan and v.count('.txt') == 1}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{1: 'rcp/安装与调试/软件安装（AIC部署）-SDN/配置虚机弹扩.txt',\n",
       " 2: 'rcp/故障管理/故障处理/业务故障/配置类业务故障/PCF侧建立专载失败，发起Rx-ASR释放.txt',\n",
       " 3: 'director/描述/产品描述/主要功能/资源管理/资源调配.txt',\n",
       " 4: 'rcp/特性指导/套餐业务类特性/ZUF-59-55-051 VoNR/特性描述.txt',\n",
       " 5: 'director/操作与维护/用户指南/租户操作指南/组织管理员操作指南/虚机发布管理/发布虚机.txt',\n",
       " 6: 'rcp/特性指导/套餐业务类特性/ZUF-59-55-051 VoNR/特性描述.txt',\n",
       " 7: 'rcp/特性指导/套餐业务类特性/ZUF-59-55-051 VoNR/特性描述.txt',\n",
       " 10: 'rcp/安装与调试/初始配置（手工部署）/PCF对接数据配置/配置SMF对接数据.txt',\n",
       " 12: 'director/操作与维护/容灾/容灾对接指南.txt',\n",
       " 13: 'rcp/故障管理/应急处理/故障信息采集/信令跟踪.txt',\n",
       " 14: 'rcp/特性指导/套餐业务类特性/ZUF-59-55-051 VoNR/特性描述.txt',\n",
       " 15: 'director/安装与调试/TCF部署TECS Director/部署前准备/准备模板.txt',\n",
       " 16: 'director/安装与调试/TCF部署TECS Director/执行部署/命令行部署.txt',\n",
       " 18: 'director/安装与调试/配置指南/资源配置管理/虚机规格管理/发布虚机规格.txt',\n",
       " 19: 'rcp/特性指导/接口类特性/FL-07-01-002 中移策略报表/特性配置.txt',\n",
       " 20: 'director/安装与调试/配置指南/子组织管理/创建子组织/创建子组织.txt',\n",
       " 21: 'emsplus/描述/产品描述(Reporting)/功能与业务/报表查询/流量报表.txt',\n",
       " 24: 'umac/ROSNG告警处理/2-告警条目说明(重用2).txt\\n',\n",
       " 25: 'umac/配置管理描述/配置数据的配置方式.txt',\n",
       " 26: 'umac/网元介绍/系统原理/系统架构.txt',\n",
       " 27: 'umac/特性指导/Common特性/ZUF-76-12业务维护增强功能/ZUF-76-12-001 DUMP.txt',\n",
       " 28: 'umac/操作与维护/信令跟踪/CN跟踪(OAM)/AMF用户信令跟踪.txt',\n",
       " 29: 'umac/故障管理/应急处理/典型故障场景/大量用户无法注册/激活.txt',\n",
       " 30: 'emsplus/特性指导/Logging和IPDR功能/特性配置/配置过程.txt',\n",
       " 31: 'emsplus/特性指导/5GC日志查询功能/特性操作/专家模式/查询通用日志/设置查询结果列.txt',\n",
       " 32: 'umac/参考/业务告警处理/AMF告警/3306553345 用户License不足一级告警.txt',\n",
       " 35: 'emsplus/特性指导/告警管理功能/特性操作/告警处理.txt',\n",
       " 37: 'umac/参考/性能计数器参考（AMF）/计数器简介.txt',\n",
       " 38: 'emsplus/故障管理/巡检指导/各节点虚拟机运行情况检查/MDS节点检查/检查虚拟机硬盘占用情况.txt',\n",
       " 39: 'umac/特性指导/Common特性/ZUF-76-02 NFV/ZUF-76-02-004 支持多个IaaS云平台.txt',\n",
       " 40: 'umac/网元介绍/系统原理/服务框架/服务组成.txt',\n",
       " 41: 'umac/特性指导/Common特性/ZUF-76-12 业务维护增强功能/ZUF-76-12-003 CHR/特性描述.txt',\n",
       " 42: 'emsplus/描述/产品描述（Logging）/产品结构/系统架构.txt',\n",
       " 43: 'umac/参考/性能计数器参考（SGSN&MME）/计数器简介.txt',\n",
       " 44: 'umac/参考/命令参考/MMESGSN/大数据查询/无线信息查询.txt',\n",
       " 47: 'umac/网元介绍/安全描述/管理平面.txt',\n",
       " 48: 'umac/网元介绍/安全描述/管理平面.txt',\n",
       " 49: 'emsplus/特性指导/5GC日志查询功能/特性操作/专家模式/查询通用日志.txt',\n",
       " 50: 'umac/参考/业务告警处理.txt'}"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "id2source"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 保存为本地文件\n",
    "import json\n",
    "with open('id2source.json', 'w') as f:\n",
    "    json.dump(id2source, f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "aiops",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.14"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
